package com.tzbank.utils;

import java.util.concurrent.atomic.AtomicInteger;

public class AtomicRangeInteger {
	private final int maxValue;
	private final AtomicInteger atomicInteger;

	public AtomicRangeInteger(final int minValue, final int maxValue)
	{
		this.atomicInteger = new AtomicInteger(minValue);
		this.maxValue = maxValue;
	}

	public Integer incrAndGet()
	{
		final int value = this.atomicInteger.incrementAndGet();
		if (value > maxValue)
		{
			return null;
		}

		return value;
	}
}
